
package com.xx.entity;

import java.io.Serializable;

import com.baomidou.mybatisplus.annotation.*;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

/**
 * 
 * @TableName cqcet.article
 * @description 文章 包括了文章、新闻、通知、公告
 */
@Data
@TableName("cqcet.article")
@ApiModel
public class Article implements Serializable {
    
    /**
     * 头图
	 * 
     */
    @ApiModelProperty("头图")
    private String img;
				
    /**
     * 标题
	 * 
     */
    @ApiModelProperty("标题")
    private String title;
				
    /**
     * 类型
	 * 
     */
    @ApiModelProperty("类型")
    private String type;
				
    /**
     * 摘要
	 * 
     */
    @ApiModelProperty("摘要")
    private String digest;
				
    /**
     * 时间
	 * 
     */
    @ApiModelProperty("时间")
    private String time;
				
    /**
     * 发布人
	 * 
     */
    @ApiModelProperty("发布人")
    private String userId;
				
    /**
     * 作者
	 * 
     */
    @ApiModelProperty("作者")
    private String author;
				
    /**
     * 内容
	 * 
     */
    @ApiModelProperty("内容")
    private String content;
				
    /**
     * 热点
	 * 
     */
    @ApiModelProperty("热点")
    private Integer hot;
				
    /**
     * 启用
	 * 
     */
    @ApiModelProperty("启用")
    private Integer status;
				
    /**
     * 浏览量
	 * 
     */
    @ApiModelProperty("浏览量")
    private Double views;
				
	/**
	 * ID
	 */
	@TableId(type = IdType.ASSIGN_ID)
	@ApiModelProperty("ID")
	@JsonSerialize(using = ToStringSerializer.class)
	private Long id;
			
	/**
	 * 创建时间
	 */
	@TableField(fill = FieldFill.INSERT)
	@ApiModelProperty("创建时间")
	@JsonSerialize(using = ToStringSerializer.class)
	private Long createTime;
				  
	/**
	 * 创建时间
	 */
	@TableField(fill = FieldFill.INSERT)
	@ApiModelProperty("创建时间")
	private String createTimeString;
					
	/**
	 * 更新时间
	 */
	@TableField(fill = FieldFill.UPDATE)
	@ApiModelProperty("更新时间")
	@JsonSerialize(using = ToStringSerializer.class)
	private Long updateTime;
					
	/**
	 * 更新时间
	 */
	@TableField(fill = FieldFill.UPDATE)
	@ApiModelProperty("更新时间")
	private String updateTimeString;
					
	/**
	 * 逻辑删除控制
	 */
	@ApiModelProperty("逻辑删除控制")
	@TableLogic
	private Integer state;
			  
	/**
	 * 单位
	 */
	@TableField(fill = FieldFill.INSERT)
	@ApiModelProperty("单位")
	private String unitId;
					
	
	/**
	 * 设置头图
	 */
	public void setImg(String img){
		this.img = img;
	}

	/**
	 * 获取头图
	 */
	public String getImg(){
		return this.img;
	}
		
	/**
	 * 设置标题
	 */
	public void setTitle(String title){
		this.title = title;
	}

	/**
	 * 获取标题
	 */
	public String getTitle(){
		return this.title;
	}
		
	/**
	 * 设置类型
	 */
	public void setType(String type){
		this.type = type;
	}

	/**
	 * 获取类型
	 */
	public String getType(){
		return this.type;
	}
		
	/**
	 * 设置摘要
	 */
	public void setDigest(String digest){
		this.digest = digest;
	}

	/**
	 * 获取摘要
	 */
	public String getDigest(){
		return this.digest;
	}
		
	/**
	 * 设置时间
	 */
	public void setTime(String time){
		this.time = time;
	}

	/**
	 * 获取时间
	 */
	public String getTime(){
		return this.time;
	}
		
	/**
	 * 设置发布人
	 */
	public void setUserId(String userId){
		this.userId = userId;
	}

	/**
	 * 获取发布人
	 */
	public String getUserId(){
		return this.userId;
	}
		
	/**
	 * 设置作者
	 */
	public void setAuthor(String author){
		this.author = author;
	}

	/**
	 * 获取作者
	 */
	public String getAuthor(){
		return this.author;
	}
		
	/**
	 * 设置内容
	 */
	public void setContent(String content){
		this.content = content;
	}

	/**
	 * 获取内容
	 */
	public String getContent(){
		return this.content;
	}
		
	/**
	 * 设置热点
	 */
	public void setHot(Integer hot){
		this.hot = hot;
	}

	/**
	 * 获取热点
	 */
	public Integer getHot(){
		return this.hot;
	}
		
	/**
	 * 设置启用
	 */
	public void setStatus(Integer status){
		this.status = status;
	}

	/**
	 * 获取启用
	 */
	public Integer getStatus(){
		return this.status;
	}
		
	/**
	 * 设置浏览量
	 */
	public void setViews(Double views){
		this.views = views;
	}

	/**
	 * 获取浏览量
	 */
	public Double getViews(){
		return this.views;
	}
		
	/**
	 * 设置ID
	 */
	public void setId(Long id){
		this.id = id;
	}

	/**
	 * 获取ID
	 */
	public Long getId(){
		return this.id;
	}
		
	/**
	 * 设置创建时间
	 */
	public void setCreateTime(Long createTime){
		this.createTime = createTime;
	}

	/**
	 * 获取创建时间
	 */
	public Long getCreateTime(){
		return this.createTime;
	}
		
	/**
	 * 设置创建时间
	 */
	public void setCreateTimeString(String createTimeString){
		this.createTimeString = createTimeString;
	}

	/**
	 * 获取创建时间
	 */
	public String getCreateTimeString(){
		return this.createTimeString;
	}
		
	/**
	 * 设置更新时间
	 */
	public void setUpdateTime(Long updateTime){
		this.updateTime = updateTime;
	}

	/**
	 * 获取更新时间
	 */
	public Long getUpdateTime(){
		return this.updateTime;
	}
		
	/**
	 * 设置更新时间
	 */
	public void setUpdateTimeString(String updateTimeString){
		this.updateTimeString = updateTimeString;
	}

	/**
	 * 获取更新时间
	 */
	public String getUpdateTimeString(){
		return this.updateTimeString;
	}
		
	/**
	 * 设置逻辑删除控制
	 */
	public void setState(Integer state){
		this.state = state;
	}

	/**
	 * 获取逻辑删除控制
	 */
	public Integer getState(){
		return this.state;
	}
		
	/**
	 * 设置单位
	 */
	public void setUnitId(String unitId){
		this.unitId = unitId;
	}

	/**
	 * 获取单位
	 */
	public String getUnitId(){
		return this.unitId;
	}
		
	public String stringify(){
		String rc = "{\"img\":\"" + this.getImg() + "\",\"title\":\"" + this.getTitle() + "\",\"type\":\"" + this.getType() + "\",\"digest\":\"" + this.getDigest() + "\",\"time\":\"" + this.getTime() + "\",\"userId\":\"" + this.getUserId() + "\",\"author\":\"" + this.getAuthor() + "\",\"content\":\"" + this.getContent() + "\",\"hot\":\"" + this.getHot() + "\",\"status\":\"" + this.getStatus() + "\",\"views\":\"" + this.getViews() + "\",\"id\":\"" + this.getId() + "\",\"createTime\":\"" + this.getCreateTime() + "\",\"createTimeString\":\"" + this.getCreateTimeString() + "\",\"updateTime\":\"" + this.getUpdateTime() + "\",\"updateTimeString\":\"" + this.getUpdateTimeString() + "\",\"state\":\"" + this.getState() + "\",\"unitId\":\"" + this.getUnitId() + "\"}";
		rc = rc.replaceAll("\"null\"","null").replaceAll("\"([0-9]+)\"","$1");
        return rc;
	}

	public static Article JSONparse(String jsonString) throws JsonProcessingException {
        if(jsonString == null) return null;
		try {
            ObjectMapper objectMapper = new ObjectMapper();
            return objectMapper.readValue(jsonString,Article.class);
        }catch (JsonProcessingException e){
            return null;
        }
    }
}
    